import redis

client = redis.Redis(host='120.77.222.217', port=6379,
                     password='1qaz2wsx')
if client.ping():
    client.zadd('zset1', {
        'yuting': 100,
        'luohao': 123,
        'wanghaifei': 70
    })
    items = client.zrevrange('zset1', 0, 9)
    print(items)
    print(client.zscore('zset1', 'yuting'))
    # print(list(map(bytes.decode, items)))
    # client.rpush('list1', 1, 2, 20, 30, 50, 100)
    # list1 = client.lrange('list1', 0, -1)
    # print(list(map(int, list1)))
    # bytes ---decode('utf-8')---> str
    # str ---encode('utf-8')---> bytes
    # print(client.ttl('username'))
    # print(client.get('username').decode())
    # print(client.ttl('password'))
    # print(client.get('password').decode())
    # client.set('username', '骆昊', ex=120)
    # client.set('password', '123456')
else:
    print('连接失败!!!')
